package server.java.autoduel.Cars;

import java.io.Serializable;
import java.nio.ByteBuffer;

import server.java.autoduel.Network.IPacketizable;
import server.java.autoduel.Network.OPCODES;

import com.sun.sgs.app.AppContext;
import com.sun.sgs.app.ManagedObject;

/**
 * Represents a car
 * 
 * @author Ian Axelrod
 * @author Liz Ha
 * @author Andrew Muldowney
 * @author Edward Futch
 */
public class Car implements ManagedObject, Serializable, IPacketizable {
	private static final long serialVersionUID = 805709463849050098L;
	/**
	 * The name of the car
	 */
	private String name;

	/**
	 * The cost of the car
	 */
	private Integer cost;

	/**
	 * The amount of armor provided by this car
	 */
	private Integer armor;

	/**
	 * The handling class for this car
	 */
	private Integer handlingClass;

	/**
	 * The amount of space available for this car
	 */
	private Integer spacesAvailable;

	/**
	 * The image of the car
	 */
	private String image;

	/**
	 * Creates an instance of a car
	 * 
	 * @param name
	 *            the name of the car
	 * @param cost
	 *            the cost of the car
	 * @param maxSpeed
	 *            the maximum speed of the car
	 * @param maxAccel
	 *            the maximum acceleration of the car
	 * @param armor
	 *            the armor of the car
	 * @param handlingClass
	 *            the handling class of the car
	 * @param spacesAvailable
	 *            the amount of space available in the car
	 */
	public Car(String name, Integer cost, Integer armor, Integer handlingClass,
			Integer spacesAvailable, String image) {
		this.name = name;
		this.cost = cost;
		this.armor = armor;
		this.handlingClass = handlingClass;
		this.spacesAvailable = spacesAvailable;
		this.image = image;
	}

	/**
	 * Creates a copy of this car
	 * 
	 * @return a copy of the car
	 */
	public Car copy() {
		return new Car(this.name, this.cost, this.armor, this.handlingClass,
				this.spacesAvailable, this.image);
	}

	@Override
	public ByteBuffer encodePacket(OPCODES opcode) {
		return null;
	}

	/**
	 * @return the armor
	 */
	public Integer getArmor() {
		return this.armor;
	}

	/**
	 * @return the cost
	 */
	public Integer getCost() {
		return this.cost;
	}

	/**
	 * @return the handlingClass
	 */
	public Integer getHandlingClass() {
		return this.handlingClass;
	}

	/**
	 * @return the image
	 */
	public String getImage() {
		return this.image;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * @return the spacesAvailable
	 */
	public Integer getSpacesAvailable() {
		return this.spacesAvailable;
	}

	/**
	 * @param armor
	 *            the armor to set
	 */
	public void setArmor(Integer armor) {
		AppContext.getDataManager().markForUpdate(this);
		this.armor = armor;
	}

	/**
	 * @param cost
	 *            the cost to set
	 */
	public void setCost(Integer cost) {
		AppContext.getDataManager().markForUpdate(this);
		this.cost = cost;
	}

	/**
	 * @param handlingClass
	 *            the handlingClass to set
	 */
	public void setHandlingClass(Integer handlingClass) {
		AppContext.getDataManager().markForUpdate(this);
		this.handlingClass = handlingClass;
	}

	/**
	 * @param image
	 *            the image to set
	 */
	public void setImage(String image) {
		AppContext.getDataManager().markForUpdate(this);
		this.image = image;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		AppContext.getDataManager().markForUpdate(this);
		this.name = name;
	}

	/**
	 * @param spacesAvailable
	 *            the spacesAvailable to set
	 */
	public void setSpacesAvailable(Integer spacesAvailable) {
		AppContext.getDataManager().markForUpdate(this);
		this.spacesAvailable = spacesAvailable;
	}

	@Override
	public String toString() {
		return "name: " + this.name + " -- cost: " + this.cost + " -- armor: "
				+ this.armor + " -- HC: " + this.handlingClass
				+ " -- spacesAvailable: " + this.spacesAvailable
				+ " -- image: " + this.image;
	}

	/*
	 * drive() reverse() turnLeft() turnRight() shoot() swapWeapon(target :
	 * Weapon)
	 */

}